#ifndef _UIACCELEROMETER_PRIVATE_H_
#define _UIACCELEROMETER_PRIVATE_H_

#include <QThread>

typedef struct {
    char        _time[8];
    quint16     code;
    quint16     type;
    quint32     value;
} UIAccelerometerEventData;

class UIAccelerometerThread : public QThread {
    Q_OBJECT

    public:
        UIAccelerometerThread (QObject *parent = 0);
        ~UIAccelerometerThread();

        unsigned long updateInterval (void) const { return m_updateInterval; }
        void setUpdateInterval (unsigned long t) { m_updateInterval = t; }

        void abort (void) { m_abort = true; }

    Q_SIGNALS:
        void accelerate (qreal x, qreal y, qreal z);

    protected:
        void run (void);

    private:
        unsigned long m_updateInterval;
        int m_cx, m_cy, m_cz;
        bool m_abort;
};

class UIAccelerometerReader {
    public:
        UIAccelerometerReader (const char *deviceName);
        ~UIAccelerometerReader();

        bool canRead (void) const;
        bool processData (int *x, int *y, int *z);

    private:
        bool readData (int *x, int *y, int *z);
        bool readAccelerometerEventData (UIAccelerometerEventData *eventData);

    private:
        int m_fd;
};

#endif /* !_UIACCELEROMETER_PRIVATE_H_ */

